package net.zhengxinyun.unifyApp.service.message;

import com.sirdc.modules.utils.ObjectUtils;
import net.zhengxinyun.unifyApp.entity.message.DailyOperation;
import net.zhengxinyun.unifyApp.filter.message.DailyOperationFilter;
import net.zhengxinyun.unifyApp.mapper.message.DailyOperationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DailyOperationServiceImpl implements DailyOperationService {

    @Autowired
    private DailyOperationMapper mapper;

    @Override
    public int saveDailyOperation(DailyOperation dailyOperation) {
        return mapper.saveDailyOperation(dailyOperation);
    }

    @Override
    public List<DailyOperation> getDailyOperations() {
        return mapper.getDailyOperations();
    }

    @Override
    public DailyOperation getDailyOperationByDataTime(String dataTime) {
        DailyOperation dailyOperation =  mapper.getDailyOperationByDataTime(dataTime);
        if(ObjectUtils.isNotBlank(dailyOperation)){
            String content = dailyOperation.getContent().replace("★","\n★");
            dailyOperation.setContent(content);
            return dailyOperation;
        }else{
            return null;
        }
    }

    @Override
    public int updateDailyOperation(DailyOperation dailyOperation) {
        return mapper.updateDailyOperation(dailyOperation);
    }
}
